package com.kawins.mina.core;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import com.kawins.mina.net.HttpRequestMessage;
import com.kawins.mina.net.HttpResponseMessage;

/**
 * Created by think on 2016/1/5.
 */
public class MethodInvoker {

	protected Object instance;
	protected Method m;

	public MethodInvoker(Object instance, Method m) {
		this.instance = instance;
		this.m = m;
	}

	public boolean invoke(HttpRequestMessage request, HttpResponseMessage response) {
		try {
			this.m.invoke(instance, new Object[] { request, response });
			return true;
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
		return false;
	}
}
